package org.itest.jci.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.itest.jci.v1.JCompilerInvoker;
import org.itest.jci.v2.CompilerRunBoostHandler;

/**
 * @author sunxinhe
 */
@RestController
public class ClientController {


    @GetMapping("/v1/")
    public String v1(
            @RequestParam String className,
            @RequestParam String method,
            @RequestParam String codes
    ) {

        JCompilerInvoker.invoke(className, method, codes);

        return "Success";
    }


    @GetMapping("/v2/")
    public String v2(
            @RequestParam String codes
    ) {

        try {
            CompilerRunBoostHandler.compiler(codes);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "Success";
    }

    @GetMapping("/v21/")
    public String v21(
    ) {

        try {
            CompilerRunBoostHandler.runcode();
        } catch (Exception e) {
            e.printStackTrace();
        }

        return "Success";
    }
}
